package com.kapcb.context.configuration;

import com.kapcb.context.bean.MapStruct;
import io.github.linpeilie.Converter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * <a>Title: MapStructConfiguration </a>
 * <a>Author: cb <a>
 * <a>Description: MapStructConfiguration <a>
 *
 * @author cb
 * @version 1.0
 * @date 2025/3/14 上午9:56
 * @since 1.0
 */
@Slf4j
@Order(Ordered.LOWEST_PRECEDENCE)
@Configuration(proxyBeanMethods = false)
public class MapStructConfiguration {

    @Bean("mapStruct")
    @ConditionalOnMissingBean(name = "mapStruct")
    public MapStruct mapStruct(Converter converter) {
        if (log.isDebugEnabled()) {
            log.debug("begin load mapStruct into IOC ...");
        }
        return new MapStruct(converter);
    }
}
